package homework.day04;

import java.util.Arrays;
import java.util.Random;

/**
 * @author ThinkBook
 */
public class Test09 {
    public static void main(String[] args) {
//定义一个长度为100的数组存放随机生成的数据
        int[] randomArr = new int[100];
//定义统计数组
        int[] countArr = new int[6];
//初始化数组randomArr
        Random r = new Random();
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        int count5 = 0;
        int count6 = 0;
        for (int i = 0;i<100;i++){
            int n = r.nextInt(6-1+1)+1;
            randomArr[i] = n;
        }
        //统计每个数字出现的概率，最终填入countArr中
            for (int j = 0;j<100;j++) {
                if (randomArr[j] == 1) {
                    count1 = count1 + 1;
                } else if (randomArr[j] == 2) {
                    count2 = count2 + 1;
                } else if (randomArr[j] == 3) {
                    count3 = count3 + 1;
                } else if (randomArr[j] == 4) {
                    count4 = count4 + 1;
                } else if (randomArr[j] == 5) {
                    count5 = count5 + 1;
                } else if (randomArr[j] == 6) {
                    count6 = count6 + 1;
                }
            }
        countArr[0] = count1;
        countArr[1] = count2;
        countArr[2] = count3;
        countArr[3] = count4;
        countArr[4] = count5;
        countArr[5] = count6;
//输出每个数字出现的概率
        System.out.println(Arrays.toString(countArr));
    }
}
